/*****************************************************************************
 *   Copyright 2005 Tim A Wang
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 ****************************************************************************/
package com.jb.web.bean.custom;

import com.jb.framework.PersistentContext;
import com.jb.web.bean.Image;
import com.jb.web.bean.ListBox;
import com.jb.web.bean.Table;
import com.jb.web.bean.TableCell;
import com.jb.web.bean.TableRow;


public class Shuttle extends Table {
    static final long serialVersionUID = 123123L;
    
    public void setDefault(PersistentContext pCtx) {
        // super.setDefault(pCtx);
        setRows(0);
        setColumns(3);
        setRows(2);

        setCellPadding(3);
        valueChanged(pCtx);
        TableRow row = getRow(0);;
        row.setCols(3);
        row.valueChanged(pCtx);
        getRow(1).setCols(1);
        getRow(1).valueChanged(pCtx);

        TableCell cell_11 = row.getCellAt(0);
        cell_11.setRowSpan(2);

        TableCell cell_12 = row.getCellAt(1);
        TableCell cell_13 = row.getCellAt(2);

        TableCell cell_22 = getRow(1).getCellAt(0);
        cell_22.setValue("&gt;");
        cell_22.setVerticalAlign("top");
        cell_12.setValue("&lt;");
        cell_12.setVerticalAlign("bottom");

        cell_11.setStyleClass(null);
        cell_22.setStyleClass(null);
        cell_12.setStyleClass(null);
        cell_13.setStyleClass(null);

        ListBox left = new ListBox();
        ListBox right = new ListBox();

        left.setOnDblClick("JavaBase.DomUtil.moveOptions('" + left.getClientId() + "', '" + right.getClientId() +
            "');");
        right.setOnDblClick("JavaBase.DomUtil.moveOptions('" + right.getClientId() + "', '" + left.getClientId() +
            "');");
        left.addValueChangeListener(this);
        right.addValueChangeListener(this);

        Image imgLeft = new Image();
        Image imgRight = new Image();

        imgRight.setLocation("resources/images/palette/rightArrowActive.gif");
        imgLeft.setLocation("resources/images/palette/leftArrowActive.gif");
        imgRight.setOnClick("JavaBase.DomUtil.moveOptions('" + left.getClientId() + "', '" + right.getClientId() +
            "');");
        imgLeft.setOnClick("JavaBase.DomUtil.moveOptions('" + right.getClientId() + "', '" + left.getClientId() +
            "');");

        imgLeft.setDestination("javascript:void(0);");
        imgRight.setDestination("javascript:void(0);");
        cell_22.addFacet(imgLeft.getId(), imgLeft);
        cell_12.addFacet(imgRight.getId(), imgRight);
        left.setWidth("120px");
        right.setWidth("120px");
        left.setHeight("100px");
        right.setHeight("100px");

        cell_11.addFacet("1", left);
        cell_13.addFacet("2", right);
        cell_13.setRowSpan(2);
    }
}
